package com.cqqs.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cqqs.controller.dto.req.test.TestSingleTableReq;
import com.cqqs.mapper.TestMapper;
import com.cqqs.mapper.po.TechContact;
import com.cqqs.mapper.po.extend.ProjectPageExtend;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * 测试服务
 *
 * @author mjxie
 * @date 2022/09/20
 */
@Service
public class TestService {
    private final TestMapper mapper;

    @Autowired
    public TestService(TestMapper mapper) {
        this.mapper = mapper;
    }


    /**
     * 分页查询测试
     *
     * @param req
     * @return
     */
    public List<TechContact> testSingleTablePage(TestSingleTableReq req) {
        LambdaQueryWrapper<TechContact> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        String name = req.getName();
        if (StringUtils.hasText(name)) {
            lambdaQueryWrapper.like(TechContact::getName, name);
        }
        List<TechContact> list = mapper.selectList(lambdaQueryWrapper);
        return list;
    }


    /**
     * 多表分页测试
     *
     * @param req
     * @return
     */
    public List<ProjectPageExtend> testMultiTablePage(TestSingleTableReq req) {
        List<ProjectPageExtend> list = mapper.selectMultiTablePage(req);
        return list;

    }
}
